<template>
  <div>
    <table>
      <tr is="Hang" v-for="(item, index) in goodsArr" :key="index" :obj="item" :index="index"></tr>
    </table>
    <p>All Number:{{total}}</p>
  </div>
</template>

<script>
import Hang from "./components/Hang.vue";
export default {
  components: {
    Hang,
  },
  computed: {
      total(){
return this.goodsArr.reduce((accu,val) =>{ return accu+val.count},0)
      }
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
};
</script>

<style>
</style>